<?php
//读文件;
//df_readfile->_frdf
function _frdf($filename)
{
	$file = @fopen($filename,"r");
	$ret=false;
	if($file)
	{
		while(! feof($file)){
		$ret=$ret.fgets($file)."  ";
		}
		fclose($file);
	}
    return $ret;
}
//追加 
//df_writefile_append_content
function _fwfa($filename,$conntent)
{ 
	$file=fopen($filename,"a+b");
	$ret =fwrite($file,$conntent);
	fclose($file);
	return  $ret;
}

//覆盖
//df_writefile_cover
function _fwf($filename,$conntent)
{  
	$file=fopen($filename,"w+b");
	$ret =fwrite($file,$conntent);
	fclose($file);
	return  $ret;
}


//实现print_r的功能
function print_my($v,$print_my_left=-1,$ret=""){
$print_my_left+=1;
if (is_array($v)||is_object($v) ){
    $ret=$ret."Array\n";
    $ret=$ret.str_repeat('  ',$print_my_left*4);
    $ret=$ret."{\n";
   foreach ($v as $key=>$val)
	{
    $ret=$ret.str_repeat('  ',$print_my_left*4+2);
	$ret=$ret."[$key] => ";
        if (is_array($val)||is_object($val))
	    {
			$ret=print_my($val,$print_my_left,$ret);}
        else 
	    {$ret=$ret."$val\n";}
    }
   $ret=$ret.str_repeat('  ',$print_my_left*4);
   $ret=$ret."}\n";
}
else 
{  $ret=$ret.$v;
}
   return "".$ret."";
}
function print_my2($v,$print_my_left=-1,$ret="MY____"){
$print_my_left+=1;
if (is_array($v) ){
    $ret=$ret."Array\n";
    $ret=$ret.str_repeat('  ',$print_my_left*4);
    $ret=$ret."{\n";
   foreach ($v as $key=>$val)
	{
    $ret=$ret.str_repeat('  ',$print_my_left*4+2);
	$ret=$ret."[$key] => ";
        if (is_array($val))
	    {
			$ret=print_my2($val,$print_my_left,$ret);}
        else 
	    {$ret=$ret."$val\n";}
    }
   $ret=$ret.str_repeat('  ',$print_my_left*4);
   $ret=$ret."}\n";
}
else 
{  $ret=$ret.$v;
}
   return $ret;
}
//实现str_repeat的功能
function _ssrp($str='  ',$num=10,$cn=0){
	$cn=$cn+1;
    if($num==0){return "";}
	else
    {$temp=$str;}
return $num>$cn ? $temp._ssrp($str,$num,$cn) : $temp;		
}
function _gufunc(){
	$array=get_defined_functions();
	return $array['user'];
}
function _spre($str){
    return '<pre>'.$str.'</pre>';
}
//数据类型转换
function object_to_array($obj){
$_arr = is_object($obj)? get_object_vars($obj) :$obj;
foreach ($_arr as $key => $val){
$val=(is_array($val)) || is_object($val) ? object_to_array($val) :$val;
$arr[$key] = $val;
}
return $arr;   
}
?>